$(document).ready(function(){

    var head = document.getElementsByTagName('head').item(0);

    // Add jQuery UI
    var uiScript = document.createElement('script');
    uiScript.setAttribute('type', 'text/javascript');
    uiScript.setAttribute('src', '/vsc/js/jquery.ui.custom.min.js');
    head.appendChild(uiScript);

    // Add glossary Json data.
    var gjScript = document.createElement('script');
    gjScript.setAttribute('type', 'text/javascript');
    gjScript.setAttribute('src', '/vsc/js/glossaryJson.js');
    head.appendChild(gjScript);

    // Add image manager script.
    var imScript = document.createElement('script');
    imScript.setAttribute('type', 'text/javascript');
    imScript.setAttribute('src', '/vsc/js/image_mngr/image_mngr.js');
    head.appendChild(imScript);

    // Add file manager script.
    var fmScript = document.createElement('script');
    fmScript.setAttribute('type', 'text/javascript');
    fmScript.setAttribute('src', '/vsc/js/file_mngr/file_mngr.js');
    head.appendChild(fmScript);

    // Add analytic data gathering script.
    var alScript = document.createElement('script');
    alScript.setAttribute('type', 'text/javascript');
    alScript.setAttribute('src', '/vsc/js/analytic.js');
    head.appendChild(alScript);
    
    // JavaScript Error Handler
    /*
    function customHandler( desc,page,line,chr ){

            if ( $('#errorAjaxHolder').length == 0 ) $('body').append('<span id=\'errorAjaxHolder\' style=\'display:none\'></span>');

            var ajaxParms =
                    'error_description=' + encodeURIComponent(desc) +
                    '&page_address='     + encodeURIComponent(page) +
                    '&line_number='      + line +
                    '&browser_name='     + encodeURIComponent(navigator.appName) +
                    '&browser_version='  + encodeURIComponent(navigator.appVersion) +
                    '&platform='         + encodeURIComponent(navigator.platform);

            $('#errorAjaxHolder').html('Error...').load('/vsc/js/report_error_ajax.php #errorReport',ajaxParms);

            return true
    }
    window.onerror = customHandler;
    */



});

	
$(window).load(function() {
	checkImages();
});

//
//
//
function checkImages(){


    //alert('checkImages');
    $('img').each(function() {

        imgOk = true;
        if ( $.browser.msie ){
            //if ( !this.complete ) imgOk = false; // IE Is not working......
        } else if ( typeof this.naturalWidth == "undefined" || this.naturalWidth == 0 ){
            imgOk = false;
        }

        if ( !imgOk ){
            // image was broken, replace with your new image
            this.src = '/vsc/graphics/content-unavailable.gif';
            this.width = '94';
            this.height = '62';
        }
    });
}

//
//
//
function isInt(sText){
    var regex=new RegExp('^[0-9]+$');
    return regex.test(str);
    /*
       var ValidChars = "0123456789";
       var IsNumber=true;
       var Char;

       for (i = 0; i < sText.length && IsNumber == true; i++)
          {
          Char = sText.charAt(i);
          if (ValidChars.indexOf(Char) == -1)
             {
             IsNumber = false;
             }
          }
       return IsNumber;
       */
}
